from starlette.endpoints import HTTPEndpoint
from starlette.responses import JSONResponse
from model.ModPowerSupplyStationList import PowerSupplyStationList, stationListSchema
from database import Session, engine
import datetime


def get_station_info_all(session, bureauid: str):
    # 供电所信息all
    station_info = session.query(PowerSupplyStationList).filter(PowerSupplyStationList.bureauid == bureauid).all()
    return JSONResponse(stationListSchema.dump(station_info, many=True).data)


def get_station_info_single(session, bureauid: str, stationid: str):
    # 供电所信息single
    station_info = session.query(PowerSupplyStationList).filter(PowerSupplyStationList.bureauid == bureauid).filter(
        PowerSupplyStationList.stationid == stationid).one_or_none()
    return JSONResponse(stationListSchema.dump(station_info, many=False).data)
